/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package filer;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.xml.sax.SAXException;

/**
 *
 * @author maggie
 */
public class UrlShortcutFactory {

	public UrlShortcut getInstance(String fileName) {
		// ToDo File Not Found, unsupprted extention
		String extention = UrlShortcut.getExtention(fileName);
		String ext = extention.toLowerCase();
		UrlShortcut instance = null;
		try {
			if (ext.equals("webloc")) {
				instance = new Webloc(fileName);
			} else if (ext.equals("url")) {
				instance = new IniFile(fileName);
			} else if (ext.equals("website")) {
				instance = new IniFile(fileName);
			}
		} catch (ParserConfigurationException ex) {
			Logger.getLogger(UrlShortcutFactory.class.getName()).log(Level.SEVERE, null, ex);
		} catch (SAXException ex) {
			Logger.getLogger(UrlShortcutFactory.class.getName()).log(Level.SEVERE, null, ex);
		} catch (IOException ex) {
			Logger.getLogger(UrlShortcutFactory.class.getName()).log(Level.SEVERE, null, ex);
		} catch (XPathExpressionException ex) {
			Logger.getLogger(UrlShortcutFactory.class.getName()).log(Level.SEVERE, null, ex);
		}
		return instance;
	}

}
